﻿<?php
	@session_start();
	include("../../connect/connect_mysql.php");
	$act= $_POST['act'];
	
	if($act == 'content_event'){
		$query = "SELECT * FROM event WHERE is_deleted = '0' ORDER BY `date` DESC";
	 	mysql_query ("SET NAMES 'utf8'");
	 	$result = mysql_query($query) or die(mysql_error());
		$arr_table_result= mysql_fetch_full_result_array($result);
		echo ($arr_table_result);
	}
	if ($act == 'innit'){
		$id = $_POST['id'];
		$query = "SELECT * FROM event WHERE event_id='$id' and is_deleted = '0'";
		mysql_query ("SET NAMES 'utf8'");
	 	$rs = mysql_query($query) or die(mysql_error());
		if($rs){
	 		echo mysql_fetch_full_result_array($rs);
		}else{
			echo "";
		}
	}
	if ($act == 'edit_event'){
		$time = $_POST['time'];
		$d = $_POST['date'];
		$id = $_POST['id'];
		$name = $_POST['name_event'];
		$info = $_POST['info'];
		$info=str_replace(chr(13),"",$info);
		$info=str_replace("\n",".-",$info);
		$query = "UPDATE `event` SET `date`='$d', `time`='$time', `name`='$name', `info`='$info' WHERE `event_id`='$id';";
		mysql_query ("SET NAMES 'utf8'");
		mysql_query($query);
		echo 1;
	}
	if ($act == 'view_image'){
		$id = $_POST['id'];
		$query = "SELECT img.image_id,img.path,img.comment,img.is_deleted FROM `image` img,`event` e WHERE  img.date =  e.date AND img.time = e.`time` AND e.event_id = '$id' and img.is_deleted = '0'";
		mysql_query ("SET NAMES 'utf8'");
		$rs = mysql_query($query);
		if($rs){
	 		echo mysql_fetch_full_result_array($rs);
		}else{
			echo "";
		}
	}
	if ($act == 'delete_event'){
		$ids =$_POST['ids'];
		$query = "UPDATE `event` SET `is_deleted` = '1' WHERE `event_id` IN ($ids)";
		mysql_query ("SET NAMES 'utf8'");
		$rs = mysql_query($query);
		echo 1;
	}
?>
	